#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define MAX_LEN 256

typedef struct {
    char data[MAX_LEN];
    int top;
} CharStack;

typedef struct {
    double data[MAX_LEN];
    int top;
} DoubleStack;

void initCharStack(CharStack *stack) {
    stack->top = -1;
}

int isCharStackEmpty(CharStack *stack) {
    return stack->top == -1;
}

void pushCharStack(CharStack *stack, char c) {
    stack->data[++stack->top] = c;
}

char popCharStack(CharStack *stack) {
    return stack->data[stack->top--];
}

char peekCharStack(CharStack *stack) {
    return stack->data[stack->top];
}

void initDoubleStack(DoubleStack *stack) {
    stack->top = -1;
}

int isDoubleStackEmpty(DoubleStack *stack) {
    return stack->top == -1;
}

void pushDoubleStack(DoubleStack *stack, double num) {
    stack->data[++stack->top] = num;
}

double popDoubleStack(DoubleStack *stack) {
    return stack->data[stack->top--];
}

int isOperator(char c) {
    return c == '+' || c == '-' || c == 'x' || c == '/' || c == '(' || c == ')' || c == '[' || c == ']';
}

int getPriority(char op) {
    switch (op) {
        case '+':
        case '-':
            return 1;
        case 'x':
        case '/':
            return 2;
        case '(':
        case '[':
            return 0;
        default:
            return -1;
    }
}

void infixToPostfix(char *infix, char *postfix) {
    CharStack stack;
    initCharStack(&stack);
    int i = 0, j = 0;

    while (infix[i] != '\0') {
        if (isdigit(infix[i]) || infix[i] == '.') {
            while (isdigit(infix[i]) || infix[i] == '.') {
                postfix[j++] = infix[i++];
            }
            postfix[j++] = ' ';
        } else if (infix[i] == ' ') {
            i++;
        } else if (infix[i] == '(' || infix[i] == '[') {
            pushCharStack(&stack, infix[i]);
            i++;
        } else if (infix[i] == ')' || infix[i] == ']') {
            char matchingBracket = (infix[i] == ')') ? '(' : '[';
            while (!isCharStackEmpty(&stack) && peekCharStack(&stack) != matchingBracket) {
                postfix[j++] = popCharStack(&stack);
                postfix[j++] = ' ';
            }
            if (!isCharStackEmpty(&stack) && peekCharStack(&stack) == matchingBracket) {
                popCharStack(&stack);
            } else {
                printf("Invalid expression: Unmatched parentheses or brackets\n");
                exit(1);
            }
            i++;
        } else if (isOperator(infix[i])) {
            while (!isCharStackEmpty(&stack) && getPriority(peekCharStack(&stack)) >= getPriority(infix[i])) {
                postfix[j++] = popCharStack(&stack);
                postfix[j++] = ' ';
            }
            pushCharStack(&stack, infix[i]);
            i++;
        } else {
            printf("Invalid character in expression: %c\n", infix[i]);
            exit(1);
        }
    }

    while (!isCharStackEmpty(&stack)) {
        char op = popCharStack(&stack);
        if (op == '(' || op == '[') {
            printf("Invalid expression: Unmatched parentheses or brackets\n");
            exit(1);
        }
        postfix[j++] = op;
        postfix[j++] = ' ';
    }

    postfix[j] = '\0';
}

double evaluatePostfix(char *postfix) {
    DoubleStack stack;
    initDoubleStack(&stack);
    int i = 0;

    while (postfix[i] != '\0') {
        if (postfix[i] == ' ') {
            i++;
            continue;
        }

        if (isdigit(postfix[i]) || postfix[i] == '.') {
            double num = 0.0;
            int point = 0;
            while (postfix[i] != ' ') {
                if (postfix[i] == '.') {
                    point = 1;
                    i++;
                    continue;
                }
                if (isdigit(postfix[i])) {
                    if (point == 0) {
                        num = num * 10 + (postfix[i] - '0');
                    } else {
                        num = num + (postfix[i] - '0') / pow(10, point);
                        point++;
                    }
                } else {
                    printf("Invalid number format\n");
                    exit(1);
                }
                i++;
            }
            pushDoubleStack(&stack, num);
        } else if (isOperator(postfix[i])) {
            double b = popDoubleStack(&stack);
            double a = popDoubleStack(&stack);
            double result;
            switch (postfix[i]) {
                case '+':
                    result = a + b;
                    break;
                case '-':
                    result = a - b;
                    break;
                case 'x':
                    result = a * b;
                    break;
                case '/':
                    if (b == 0) {
                        printf("Error: Division by zero\n");
                        exit(1);
                    }
                    result = a / b;
                    break;
                default:
                    printf("Invalid operator\n");
                    exit(1);
            }
            pushDoubleStack(&stack, result);
            i++;
        } else {
            printf("Invalid character in postfix expression: %c\n", postfix[i]);
            exit(1);
        }
    }

    if (stack.top != 0) {
        printf("Invalid postfix expression\n");
        exit(1);
    }

    return stack.data[0];
}

int main() {
    char infix[MAX_LEN];
    char postfix[MAX_LEN];
    fgets(infix, MAX_LEN, stdin);
    infix[strcspn(infix, "\n")] = '\0';

    infixToPostfix(infix, postfix);

    double result = evaluatePostfix(postfix);

    if (ceil(result) == floor(result)) {
        printf("%.0f\n", result);
    } else {
        printf("%.0f\n", result);
    }

    return 0;
}
